import {useWindowsStore, WindowsType} from "../store/windows";
import {ToastError, ToastInfo} from "../utils/Toast";
import {useGlobalStore} from "../store/global";
import {GetLang, GetLangKbs} from "../constant/lang/LangFunc";
import {NewChatDialog} from "../core/EntryLastDialog";


export async function CallbackMessageAddContent(data: any) {


    let storeGlobal = useGlobalStore()
    console.log("CallbackMessageAddContent data",data)
    storeGlobal.MessageAddContent(data)


}

export async function CallbackWindowChange(data: any) {
    let storeWin = useWindowsStore()
    const windowsType: WindowsType = data as WindowsType;//断言
    storeWin.ChangeWindow(windowsType)
}

// 创建新对话 IsUseSelect暂时用不到
export async function CallbackNewChat(IsUseSelect:Boolean){
    let storeWin = useWindowsStore()
    if(storeWin.CurrWindow != WindowsType.Message){
        storeWin.ChangeWindow(WindowsType.Message)
    }
    NewChatDialog()
}


export function CallbackTest(data:any){
    ToastInfo("test event事件被触发:" + data)
}


export function CallBackMouseLongClick(code:number){
    let global  =useGlobalStore()
    let storeGlobal = useGlobalStore()
    global.SetMouseLongData(String(code),GetLang(`mouse_${code}`))
    console.log("CallBackMouseLongClick",GetLang(`mouse_${code}`),code, global.CurrMouseButtonLongClick)
    //ToastInfo("test event事件被触发:" + data)
}


// export function CallBackMessageError(contentId :number, errorContent :string){
//     let global  =useGlobalStore()
//     global.SetMessageError(contentId,errorContent)
//
//     //console.log("CallBackMouseLongClick",GetLang(`mouse_${code}`),code, global.CurrMouseButtonLongClick)
// }



export function CallBackKyeBoardCombineClick(codes:Array<number>){
    let global  =useGlobalStore()

    let lang=GetLangKbs(codes)
    global.SetMHotKeyData(codes.join("+"),lang)

    console.log("CallBackKyeBoardCombineClick",lang,codes,global.CurrMouseButtonLongClick)
    //ToastInfo("test event事件被触发:" + data)
}


export function CallbackShowError(data:string,timeout=2000){
    ToastError(data,timeout)
}